package cn.daomeng.firebird.core.config.aspect;

//import io.swagger.annotations.ApiOperation;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.core.annotation.AnnotationUtils;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
//import java.lang.annotation.Annotation;
//import java.lang.reflect.Method;
//
//@Aspect
//@Order(-99)
//@Component
//public class ControllerStatisticsAspect {
//
//	public ControllerStatisticsAspect() {
//
//	}
//
//	@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
//	private void requestMapping() {
//	}
//
//	@Pointcut("@annotation(org.springframework.web.bind.annotation.GetMapping)")
//	private void getMapping() {
//	}
//	@Pointcut("@annotation(org.springframework.web.bind.annotation.PostMapping)")
//	private void postMapping() {
//	}
//	@Pointcut("@annotation(org.springframework.web.bind.annotation.PutMapping)")
//	private void putMapping() {
//	}
//	@Pointcut("@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
//	private void deleteMapping() {
//	}
//
//	@Around("requestMapping() || getMapping() || postMapping() || putMapping() || deleteMapping()")
//	public Object aroundController(ProceedingJoinPoint joinPoint) throws Throwable {
//
//		MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
//		Method method = methodSignature.getMethod();
//		String methodName = method.getName();
//		String methodNickName = methodName;
//		Annotation[][] parameterAnnotations = method.getParameterAnnotations();
//		Class[] argTypes = methodSignature.getParameterTypes();
//		Object[] args = joinPoint.getArgs();
//		String[] argNames = methodSignature.getParameterNames();
//
//
//
//		//使请求跟踪中有能力输出ApiOperation的功能字符串
//		ApiOperation apiOperationAnnotation = AnnotationUtils.findAnnotation(method, ApiOperation.class);
//		if (apiOperationAnnotation != null) {
//			//获得接口的名称，用于做接口统计
//			methodNickName= apiOperationAnnotation.value();
//
//			long beginTime = System.currentTimeMillis();
//			Object res = joinPoint.proceed(joinPoint.getArgs());
//			long endTime = System.currentTimeMillis();
//			LogFactory.info("接口["+ methodNickName+"],调用执行的时间是：" + (endTime - beginTime) + "mm");
//			return res;
//		}
//		Object res = joinPoint.proceed(joinPoint.getArgs());
//		return res;
//	}
//}
